package main

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/jinzhu/gorm"
)

func main() {
	db, err := gorm.Open("mysql", "root:root@(127.0.0.1)/test?charset=utf8&parseTime=True&loc=Local")
	if err != nil {
		panic(err)
	}
	var stu = new(Student)
	err = db.Table("tb_stu").Where("id = ?", 5).First(stu).Error
	if err != nil {
		panic(err)
	}
	fmt.Println(stu)
	var stus []Student
	err = db.Table("tb_stu").Where("id < ?", 5).Find(&stus).Error
	if err != nil {
		panic(err)
	}
	fmt.Println(stus)

}
